package com.jindi.jacococli.biz.business.service;

// 压缩生成的报告

import com.jindi.jacococli.biz.constant.Constant;
import com.jindi.jacococli.biz.utils.ProcessUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class ReportCompressService {

    private static final Logger LOGGER = LoggerFactory.getLogger(ReportCompressService.class);

    public boolean compress(String path) {
        File exist = new File(path + Constant.ATTACH);
        if (!exist.exists()) {
            exist.mkdirs();
        }
        String command = String.format(Constant.TAR, Constant.ATTACH, Constant.ATTACH);
        LOGGER.info("tar command:{}", command);
        return ProcessUtils.execCommand(command, new File(path));
    }

}
